package com.udf.flink.udf;
/*
 * @author: create by jianglai
 * @version: v1.0
 * @description: com.dtstack.flinksql.udf
 * @date:2021/2/8
 **/

import org.apache.flink.table.functions.ScalarFunction;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * @description：16进制转换成10进制数字。
 * @author：jianglai
 * @date：2021/2/8 7:27 下午
 */

public class Conv extends ScalarFunction {

    private static final Logger LOG = LoggerFactory.getLogger(Conv.class);
    /**
     * @author jianglai
     * @Description: TODO
     * @date 2021/2/8
     * @params [str]
     * @return java.lang.String
     */
    public String eval(String str){
        String a = null;
        try {
            if (null == str){
                a = null;
            }else {
                int i = Integer.parseInt(str, 16);
                a = String.valueOf(i);
            }
        }catch (Exception e){
            LOG.error(e.getMessage());
        }
        return a;
    }
}
